package com.zenni.utils;

import com.zenni.core.GlobalFunction;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.testng.Assert;

import java.io.File;
import java.io.IOException;

/**
 * Created by douglasj on 3/28/16.
 */
public class ScreenShotUtils {
    public void takeScreenShot(WebDriver driver,String testCaseName, boolean state) {
        try {
            String currenttime = GlobalFunction.getCurrentTimeStamp();
            File scrFile = ((TakesScreenshot) driver)
                    .getScreenshotAs(OutputType.FILE);
            FileUtils.copyFile(scrFile, new File("screenshots" + File.separator
                    + testCaseName + currenttime + ".jpg"));
            Assert.assertTrue(state);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
